<%@ page import="service.AccountService" %>
<%@ page import="java.time.format.DateTimeFormatter" %>
<%--
  Created by IntelliJ IDEA.
  User: Zafkiel
  Date: 2021/8/14
  Time: 18:25
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <script type="text/javascript" src="js/jquery-3.2.1.min.js"></script>
    <script type="text/javascript" src="js/account.js"></script>
    <link rel="stylesheet" type="text/css" href="css/mainPageMy.css">
    <link rel="stylesheet" type="text/css" href="css/mainPageWindow.css">
    <title>欢迎光临靓仔购物网！- 新品上新</title>
</head>
<body id="bdy">

<%
    AccountService.LoginInfo logInfo = (AccountService.LoginInfo)session.getAttribute("OESloginInfo");
//    System.out.println("main.jsp: " + (logInfo == null? "null": logInfo.getLoginState()));
%>
<input type="hidden" id="hidUid" value="">

<div id="divMainContainer">
    <!-- ----------------------------------------内容栏---------------------------------------- -->

    <div id="divMainContent">
        <iframe scrolling="yes" id="contentFrame" name="content"></iframe>
    </div>

    <!-- ----------------------------------------顶部导航栏---------------------------------------- -->

    <div id="divMainBg">
        <div id="divLogoBG"><div id="divLogo"><img id="imgMainLogo" src="img/mainLogo.jpg"></div></div>
        <div id="divUpMenu">
            <div id="divUpSearch">
                <input type="text" id="txtSearch" placeholder="搜索商品或店铺"><input type="button" id="btnSearch" value="Go!">
            </div>
            <div id="divUpRight">
                <input type="button" class="btnUpRight" value="新品" id="btnNew">
                <input type="button" class="btnUpRight" value="分类" id="btnType">
                <input type="button" class="btnUpRight btnLighting" value="活动" id="btnActive">
                <input type="button" class="btnUpRight" value="福利" id="btnBonus">
            </div>
        </div>
    </div>

</div>

<!-- ---------------------------------------左侧 我的 栏----------------------------------------- -->

<!-- 上方 头像、昵称和 ID 部分 -->
<div id="divMy">
    <div id="divMyHead">
        <div id="divMyHeadHead">
            <div id="divMyHeadLeft"><input type="button" class="headImg big" id="btnHeadImg"></div>
            <div id="divMyHeadRight">
                <%  if(logInfo == null  ||  logInfo.getLoginState() != AccountService.LoginState.SUCCEED) { %>
                    <input type="button" id="btnLogin" value="登入">
                <%} else {%>
                    <input type="button" id="btnLogout" value="登出">
                <%}%>
            </div>
        </div>
        <%  if(logInfo == null  ||  logInfo.getLoginState() != AccountService.LoginState.SUCCEED) { %>
            <div id="divMyHeadNick">未登录</div>
            <div id="divMyHeadId">注册登录，成为靓仔！</div>
        <%} else {%>
            <div id="divMyHeadNick"><%=logInfo.getUserInfo().getU_nick()%></div>
            <div id="divMyHeadId"><%=logInfo.getUserInfo().getU_name()%></div>
        <%}%>
    </div>
    <hr class="outerHr">

    <!-- 中上 我的信息 部分 -->
    <div id="divMyInfo">
        <div id="divMyInfoUp">
            <table id="tableMyInfo">
                <tbody>
                <%  if(logInfo == null  ||  logInfo.getLoginState() != AccountService.LoginState.SUCCEED) { %>
                    <tr><td>钱包：</td><td id="tdBank"><a href="#" id="aBank">0.00￥</a></td></tr>
                    <tr><td>积分：</td><td id="tdScore">0</td></tr>
                    <tr><td>会员：</td><td id="tdVIP"><a href="#" id="aVIP">/</a></td></tr>
                    <tr><td>电话：</td><td id="tdTel">无</td></tr>
                    <tr><td class="tdQQ">QQ：</td><td class="tdQQ" id="tdQQ">无</td></tr>
                    <tr><td class="tdWechat">微信：</td><td class="tdWechat" id="tdWechat">无</td></tr>
                <%} else {%>
                    <tr><td>钱包：</td><td id="tdBank"><a href="#" id="aBank"><%=logInfo.getUserInfo().getU_bank()%>￥</a></td></tr>
                    <tr><td>积分：</td><td id="tdScore"><%=logInfo.getUserInfo().getU_score()%></td></tr>
                    <tr><td>会员：</td><td id="tdVIP"><a href="#" id="aVIP"><%=logInfo.getUserInfo().getU_vip_ddate().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"))%></a></td></tr>
                    <tr><td>电话：</td><td id="tdTel"><%=(logInfo.getUserInfo().getU_tel() == null? "无": logInfo.getUserInfo().getU_tel())%></td></tr>
                    <tr><td class="tdQQ">QQ：</td><td class="tdQQ" id="tdQQ"><%=(logInfo.getUserQQ() == null? "无": logInfo.getUserQQ())%></td></tr>
                    <tr><td class="tdWechat">微信：</td><td class="tdWechat" id="tdWechat"><%=(logInfo.getUserWechat() == null? "无": logInfo.getUserWechat())%></td></tr>
                <%}%>
                </tbody>
            </table>
        </div>
        <div id="divMyInfoDown">
            <div id="divMyInfoDownLeft"><input type="button" id="btnManageAddress" value="收货地址"></div>
            <div id="divMyInfoDownMid"></div>
            <div id="divMyInfoDownRight"><a id="aAddressCount">(0)</a></div>
        </div>
    </div>
    <hr class="outerHr">

    <!-- 中下 入口按钮 部分 -->
    <div id="divMyEntries">
        <input type="button" class="btnMyEntries" id="btnMyShopingSet" value="购物车">
        <input type="button" class="btnMyEntries" id="btnMyOrder" value="订单">
        <input type="button" class="btnMyEntries" id="btnMyFavoGoods" value="喜爱商品">
        <input type="button" class="btnMyEntries" id="btnMyFavoStores" value="收藏店铺">
        <input type="button" class="btnMyEntries" id="btnMyMessage" value="消息">
    </div>
    <hr class="outerHr">

    <!-- 下方 当老板 部分 -->
    <div id="divMyBeBoss">
        <input type="button" class="btnMyBeBoss" id="btnMyBeBoss" value="当 老 板">
    </div>
</div>
<script type="text/javascript">
    $(document).ready(function() {
        initButtons();
        <%
        String userAt = (String)session.getAttribute("OESAt");
        if(userAt != null) switch (userAt) {
            case "newGoodsPage": %>newGoodsPage();<% break;
            case "myStorePage":  %>myStorePage();<% break;
        } else {%> newGoodsPage(); <%}
        %>
    });

    function logoutBack() {
        if(confirm("真的要离开我吗T^T")) {
            location.href = "<%=request.getContextPath()%>/logout.userInfoService";
        }
    }

    function toLogin() {
        location.href= "<%=request.getContextPath()%>/login.jsp";
    }

    function initButtons(){

        $("#btnLogout").click(logoutBack);
        $("#btnLogin").click(toLogin);

        $("#btnSearch").click(function() {

        });

        $("#btnNew").click(function() {
            newGoodsPage();
        });

        $("#btnType").click(function() {

        });

        $("#btnActive").click(function() {

        });

        $("#btnBonus").click(function() {

        });

        $("#btnHeadImg").click(function() {

        });

        $("#aBank").click(function() {

        });

        $("#aVIP").click(function() {

        });

        $("#btnManageAddress").click(function() {

        });

        $("#btnMyShopingSet").click(function() {

        });

        $("#btnMyOrder").click(function() {

        });

        $("#btnMyFavoGoods").click(function() {

        });

        $("#btnMyFavoStores").click(function() {

        });

        $("#btnMyMessage").click(function() {

        });

        $("#btnMyBeBoss").click(function() {
            myStorePage();
        });

        $("#imgMainLogo").click(function() {
            newGoodsPage();
        });
    }

    function lockWindowSize() {
        var minWidth0 = document.getElementById("divMainContent").clientWidth;
        var minWidth1 = document.getElementById("divMainBg").clientWidth;
        $("#divMainContent").css("min-width", minWidth0 + "px");
        $("#divMainContent").css("max-width", minWidth0 + "px");
        $("#divMainBg").css("min-width", minWidth1 + "px");
        $("#divMainBg").css("max-width", minWidth1 + "px");
    }

    function newGoodsPage() {
        lockWindowSize();
        document.title = "靓仔购物网 - 新品上新";
        document.getElementById("contentFrame").src = "mainTypeContent.jsp";
    }

    function myStorePage() {

        <%  if(logInfo == null  ||  logInfo.getLoginState() != AccountService.LoginState.SUCCEED) {%>
            location.href= "<%=request.getContextPath()%>/login.jsp";
        <%} else {%>
            lockWindowSize();
            document.title = "靓仔购物网 - 我的店铺";
            document.getElementById("contentFrame").src = "mystore.jsp";
        <%}%>
    }
</script>
</body>
</html>
